<template>
  <div class="systemhome-container">
    <el-container style="height: 100%; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <div class="aside_title">
          <h1>博客管理系统</h1>
        </div>
        <el-menu default-active="/system/home/user"  class="el-menu-vertical-demo"
        :router="true">
          <el-submenu index="1">
            <template slot="title"
              ><i class="el-icon-user"></i>
              用户相关
            </template>
            <el-menu-item index="/system/home/user">
              用户管理
            </el-menu-item>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title"
              ><i class="el-icon-menu"></i>
              文章相关
            </template>
            <el-menu-item index="/system/home/article">
              文章管理
            </el-menu-item>
          </el-submenu>

          <el-submenu index="3">
            <template slot="title"
              ><i class="el-icon-document"></i>
              统计相关
            </template>
            <el-menu-item index="/system/home/tagstatistics">
              标签数据统计
            </el-menu-item>
            <el-menu-item index="/system/home/userstatistics">
              用户数据统计
            </el-menu-item>
          </el-submenu>

          <el-submenu index="4">
            <template slot="title"
              ><i class="el-icon-message"></i>
              留言相关
            </template>
              <el-menu-item index="/system/home/statistics">
              留言管理
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 主体部分 -->
      <el-container>
        <!-- 头部 -->
        <el-header style="text-align: right; font-size: 12px">
          <el-dropdown @command="handleCommand">
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="about">个人设置</el-dropdown-item>
              <el-dropdown-item command="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>{{username}}</span>
        </el-header>
        <!-- 中间内容部分 -->
        <el-main class="main">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'SystemHome',
  data () {
    return {
      username: ''
    }
  },
  methods: {
    handleCommand (command) {
      if (command === 'logout') {
        localStorage.removeItem('token')
        this.$router.replace('/system')
      } else {
        console.log('about')
      }
    }
  },
  created () {
    this.username = localStorage.getItem('username')
  }
}
</script>

<style lang="less" scoped>
html,
body {
  width: 100%;
  height: 100%;
}
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}
.aside_title{
  color: rgb(255, 255, 255);

}
// .el-aside {
//   color: rgb(255, 255, 255);
// }
.systemhome-container {
  width: 100%;
  height: 100%;
}

.aside_title {
  width: 100%;
  height: 60px;
  line-height: 60px;
  font-size: 20px;
  text-align: center;
  background: linear-gradient(100deg, #1c5de7, #1c91e7);
}
.el-submenu__title {
  padding: 0;
}
</style>
